@echo off
:::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Function:
::    Config check...
:: Author:
::    Tody Guo
:: Build date:
::    2016-02-05
:::::::::::::::::::::::::::::::::::::::::::::::::::::

:Config
	%ImageDrv%
	cd \

:Start
	COLOR
	cls
	echo ___________________________________________
	echo 1. NTSN141X or  NTSL141X
	echo 2. Others
	echo ___________________________________________
	set /p choice=Select model: 
	if "%choice%" == "1" goto CheckCSUP
	if "%choice%" == "2" goto CheckCSUP
	if "%choice%" == "" goto Start
goto Start

:CheckCSUP	
	set ErrMsg=No CSUP.TXT
	if not exist C:\Windows\csup.txt goto Fail

:Driver
	set ErrMsg=TP
:ELAN
	thjsj\TestFile\devcon.exe find * | find /i "ELAN Input Device"
	if %errorlevel% == 0 goto checkfile

:AVC
	thjsj\TestFile\devcon.exe find * | find /i "Finger Sensing Pad"
	if %errorlevel% == 0 goto checkfile
:SynPD
	thjsj\TestFile\devcon.exe find * | find /i "Synaptics PS/2"
	if %errorlevel% == 0 goto checkfile
goto Fail  

:checkfile

:delfile
	rd /s /q c:\thjsj\*.*
	rd /s /q c:\thjsj
	del "c:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\*.bat" /q
	del "c:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\*.lnk" /q
  
:chkfile
    set ErrMsg=Testfile exist
	if exist C:\thjsj goto Fail
    if exist "c:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\*.bat" goto Fail
    if exist "c:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\*.lnk" goto Fail

	set ErrMsg=Windows exist
	if exist D:\windows goto Fail
	if exist E:\windows goto Fail

:AUDIO
	set ErrMsg=AUDIO Fail 
	thjsj\TestFile\devcon.exe find hdaudio\* | find /i "Realtek High Definition Audio"
	if %errorlevel% == 1 goto Fail

:unknown
	set ErrMsg=Found unknown devices
	cscript /nologo thjsj\TestFile\ListUnknow.vbs | find /i "THTF: Found unknown devices"
	if %errorlevel% == 0 goto Fail
	
:ChkWin
	thjsj\process\sfc\isWin7.exe
	if %errorlevel% == 0 goto OA3
	if %errorlevel% == 1 goto NOOA3

:OA3
    set ErrMsg=OA3 Fail
    thjsj\TestFile\oa3\oemcheckmsdm.exe | find /i "error"
    if %errorlevel% == 0 goto Fail

:NOOA3
	::noop

	rem NOT NTSN141X GOTO END
    if "%choice%" == "2" goto end

:CheckGsensor
	set ErrMsg=No G-Sensor dirver 	
	if not exist "C:\Program Files\Kionix\Accelerometer HDD protection\G_sensorAP.exe" goto checkGsensor1

:CheckGsensor1
	set ErrMsg=No G-Sensor dirver   	
	if not exist C:\"Program Files"\STMicroelectronics\stdcfltn\dpinst.exe goto fail

goto End	

:Fail
	color 4f
	echo #########################################################
	echo %ErrMsg%
	echo #########################################################
	pause
goto Fail

:End
	net use * /del /yes
	COLOR 2F
